#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <utility>
using namespace std;

#define mm(a, n) memset(a, n, sizeof a)
#define mk(a, b) make_pair(a, b)

const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<int, LL> PIL;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

const int N = 1e5 + 10;

struct People{
    int id;
    int virtue, talent;
    int type;
}people[N];

int n, l, r, idx;

// 多种条件排序，按照优先级由高到低排序
bool cmp (const People & p1, const People & p2) {
    if (p1.type != p2.type)
        return p1.type > p2.type;
    if (p1.talent + p1.virtue != p2.talent + p2.virtue) 
        return p1.talent + p1.virtue > p2.talent + p2.virtue;
    if (p1.virtue != p2.virtue)
        return p1.virtue > p2.virtue;
    return p1.id < p2.id;
}

inline void solution() {

    cin >> n >> l >> r;

    for (int i = 0; i < n; i ++ ) {

        int id, vir, tal;
        cin >> id >> vir >> tal;

        if (vir < l || tal < l) continue;
        if (vir >= r && tal >= r) people[idx].type = 3;
        else if (vir >= r && tal < r) people[idx].type = 2;
        else if (vir < r && tal < r && vir >= tal) people[idx].type = 1;
        else people[idx].type = 0;
        people[idx].id = id, people[idx].talent = tal, people[idx ++ ].virtue = vir;
    }
    sort(people, people + idx, cmp);
    cout << idx << endl;
    for (int i = 0; i < idx; i ++ ) 
        cout << people[i].id << " " << people[i].virtue << " " << people[i].talent << endl;

}

int main() {
    freopen("input.txt", "r", stdin);
    quickread();
    solution();
    return 0;
}